﻿@model DotNetUniLodz.Models.ArticleModel

@{
    ViewBag.Title = "Edytuj artykuł " + Model.Article_title;
}

<div id="Content100">
    <h2>Edycja</h2>

    @using (Html.BeginForm("Edit", "Articles", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary()

        <fieldset id="CreateItem">
            <legend>Edytuj artykuł</legend>

            @Html.HiddenFor(m => m.Article_id)
            @Html.HiddenFor(m => m.Article_creationDate)
            @Html.HiddenFor(m => m.Category_id)
            @Html.HiddenFor(m => m.User_author)
            @Html.HiddenFor(m => m.Article_img)

            <div class="editor-label">
                Nazwa           
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Article_title)
                @Html.ValidationMessageFor(model => model.Article_title)
            </div>

            <div class="editor-label">
                Treść           
            </div>
            <div class="editor-field">
                @Html.Partial("EditorTemplates/tinymce_jquery_full", new DotNetUniLodz.Models.TextModel() { PropertyName = "Article_text", Value = Model == null ? string.Empty : Model.Article_text })
                @Html.ValidationMessageFor(model => model.Article_text)
            </div>

            <div class="editor-label">
                Obrazek
            </div>
            <div class="editor-field">
                @if (Model.File != null)
                {
                    <img src="~/@Model.File.File_path" alt="@Model.Article_title" class="ArticleEditImg" />
                }
                <p>
                    <input type="file" name="Img" style="width: 250px;" />

                    @if (Model.Article_img == null)
                    {
                        @Html.CheckBox("removeImg", false, new { disabled = Model.Article_img == null, style = "width:30px;" })
                    }
                    else
                    {
                        @Html.CheckBox("removeImg", false, new { style = "width:30px;" })                         
                    }
                    Usuń aktualny obrazek i ustaw pusty 
                </p>
            </div>
            <div class="editor-label showHide">
                <a onclick="$('#SelectEvent').toggle()" style="cursor: pointer; color: #5f8f28;">Podepnij wydarzenie</a>
            </div>
            <div class="editor-field" id="SelectEvent" style="display: none;">
                @Html.DropDownList("EventId", (SelectList)ViewBag.Events, "Brak wydarzenia")
            </div>            
            <div class="editor-label showHide">
                <a onclick="$('#SelectCategory').toggle()" style="cursor: pointer; color: #5f8f28;">Podepnij kategorię</a>
            </div>
            <div class="editor-field" id="SelectCategory" style="display: none;">
                @Html.DropDownList("CategoryId", (SelectList)ViewBag.Categories, "Brak kategorii")
            </div> 
            <div class="editor-label">
                Wiadomość główna           
            </div>
            <div class="editor-field">
                @Html.CheckBoxFor(model => model.Article_isMainArticle, new { style="width:20px;" })
                @Html.ValidationMessageFor(model => model.Article_isMainArticle)
            </div>
            <p>
                <input type="submit" value="Zapisz" />
            </p>
        </fieldset>
    }
    <div>
        @Html.ActionLink("Powrót do listy aktualności", "Index", null, new { @class = "SuperLink" })
    </div>
</div>

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
